<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <!--
        常用的生命周期方法（钩子、回调函数）:
        1、mounted: 发送ajax请求，启动定时器，订阅消息
        2、beforeDestory: 清除定时器、取消消息订阅

        Vue销毁了之后：DOM事件依然有效
    -->
    <!-- 准备好一个容器-->
    <div id="app">
        num的值：{{num}}<br/>
        <button @click="add">num+1</button><br/>
        <button @click="destory()">销毁Vue</button>
    </div>
    <script src="vue.js"></script>
    <script>
        Vue.config.productionTip = false //阻止 vue 在启动时生成生产提示。
        //创建vue实例
        var vm = new Vue({
            el: '#app',
            data: {
                num: 1
            },
            methods: {
                add() {
                    console.log('add()');
                    this.num++;
                },
                destory() {
                    console.log('destory11');
                    this.$destroy();
                }
            },
            beforeCreate() {
                console.log('beforeCreate');
            },
            created() {
                console.log('created');
            },
            beforeMount() {
                console.log('beforeMount');
            },
            mounted() {
                console.log('mounted');
            },
            beforeDestroy() {
                console.log('beforeDestroy');
            },
            destroyed() {
                console.log('destroyed');
            },
            beforeUpdate() {
                console.log('beforeUpdate');
            },
            updated() {
                console.log('updated');
            },
        })
    </script>
</body>

</html>